package org.xxpay.pay.channel.collpay;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import org.xxpay.common.unify.AbstractPaymentConfig;

/**
 * @Package org.xxpay.pay.channel.collpay
 * @Class: CollpayConfig.java
 * @Description: 个人收款
 * @Author leo
 * @Date 2019/3/22 16:35
 * @Version
 **/
@Component
@Data
@ToString
@NoArgsConstructor
public class CollpayConfig extends AbstractPaymentConfig {

    public static final String CHANNEL_NAME = "collpay";
    public static final String CHANNEL_NAME_ALIPAY_COLL = CHANNEL_NAME + "_alipay_coll";
    public static final String CHANNEL_NAME_UNIONQR = CHANNEL_NAME + "_unionqr";
    public static final String RETURN_VALUE_SUCCESS = "success";
    public static final String RETURN_VALUE_FAIL = "fail";
    public static final String RESPONSE_RESULT_SUCCESS = "success"; // 返回上游成功
    public static final String RESPONSE_RESULT_FAIL = "fail";       // 返回上游失败

    /**
     * 渠道类型
     */
    private String channelType;

    public CollpayConfig(String payParam) {
        Assert.notNull(payParam, "init collpay config error");
        JSONObject object = JSON.parseObject(payParam);
        setMchId(object.getString("mchId"));
        setPrivateKey(object.getString("privateKey"));
        setRequestUrl(object.getString("requestUrl"));
        setPayMode(object.getString("type"));
        setChannelType(object.getString("channelType"));
    }

}
